/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 装备数据(会入库)
	/// module : structs
	/// </summary>
	public class ItemEquipmentPOD : IPOD 
    {
        public readonly static Func<ItemEquipmentPOD> FACTORY = () => new ItemEquipmentPOD();
		public static Func<ItemEquipmentPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        ///  强化等级
        /// </summary>
		public int level;
		/// <summary>
        ///  经验	
        /// </summary>
		public int exp;
		/// <summary>
        ///  星级
        /// </summary>
		public int star;
		/// <summary>
        ///  皮肤id，默认0
        /// </summary>
		public int skinCid;
		/// <summary>
        ///  锁定状态
        /// </summary>
		public bool isLock;
		
		
		
		/*-- constructors --*/
		public ItemEquipmentPOD() {}
		public ItemEquipmentPOD(int level, int exp, int star, int skinCid, bool isLock) {
			this.level = level;
			this.exp = exp;
			this.star = star;
			this.skinCid = skinCid;
			this.isLock = isLock;
		}
		  public void Serial(SOutputStream _out) {
                if(level != default) {
                    _out.WriteByte(1);
                    _out.Write_int(level);
                }
                if(exp != default) {
                    _out.WriteByte(2);
                    _out.Write_int(exp);
                }
                if(star != default) {
                    _out.WriteByte(3);
                    _out.Write_int(star);
                }
                if(skinCid != default) {
                    _out.WriteByte(4);
                    _out.Write_int(skinCid);
                }
                if(isLock != default) {
                    _out.WriteByte(5);
                    _out.Write_boolean(isLock);
                }
        }
            
        public void UnSerial(SInputStream _in) {
            while (_in.HasRemaining())
            {
                int _key = _in.ReadByte();
                switch (_key)
                {
                    case 1:
                        level = _in.Read_int();
                        break;
                    case 2:
                        exp = _in.Read_int();
                        break;
                    case 3:
                        star = _in.Read_int();
                        break;
                    case 4:
                        skinCid = _in.Read_int();
                        break;
                    case 5:
                        isLock = _in.Read_boolean();
                        break;
                    default: _in.SkipBinary();break;
                }
            }
        }
		
		public ItemEquipmentPOD Clone() {
            ItemEquipmentPOD o = DynamicFactory();
            o.level = level;
            o.exp = exp;
            o.star = star;
            o.skinCid = skinCid;
            o.isLock = isLock;
            return o;
        }
        
        public void Clear() {
            level = default;
            exp = default;
            star = default;
            skinCid = default;
            isLock = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "ItemEquipmentPOD [";
			str += "level=";
			str += level;
			str += ", exp=";
			str += exp;
			str += ", star=";
			str += star;
			str += ", skinCid=";
			str += skinCid;
			str += ", isLock=";
			str += isLock;
			str += "]";
			return str;
		}
		
	}
}